import axios from "../utils/request";
import distUtils from "../utils/distUtils";
const state = {

}
const mutations = {
  // //保存学生列表信息
  // setStudentList: (state, data) => {
  //   state.studentList = data
  // },

}
const actions = {

  /**
   * 查询学生列表信息
   * @param commit
   * @param params
   * @returns {Promise<unknown>}
   */
  selectStudentList: function ({commit}, params) {

    return new Promise((resolve, reject) => {
      axios.get('/student/list',{params:params}).then((res) => {
        const studentList = distUtils.getDataList(res.data,"全部学生","id","studentName")
        resolve(studentList)
      }).catch((error) => {
        reject(error)
      })

    }).catch(error=>{
      console.log(error)
    })

  },

  /**
   * 查询课程表信息
   * @param commit
   * @param params
   * @returns {Promise<unknown>}
   */
  selectDistType: function ({commit}, params) {
    // const param = {dictType:'course_type'}
    return new Promise((resolve, reject) => {
      axios.get('/baseDict/findDistListByType',{params:params}).then((res) => {
        const newDataList = distUtils.getDistList(res.data)
        // commit("setDistDataList", params.dictType,newDataList)
        resolve(newDataList)
      }).catch((error) => {
        reject(error)
      })

    }).catch(error=>{
      console.log(error)
    })

  },


}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
